﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace ace_pso.Utility
{
    /// <summary>
    /// BCD码操作
    /// zgke@sina.com
    /// qq:116149
    /// </summary>
    public class BCD
    {
        public static string GetByBinary(int InputValue)
        {
            byte k = 0; int temp;
            const int SHIFT = sizeof(int) * 8 - 1;
            char[] OutString = new char[SHIFT + 1];
            const int Mask = (int)1 << SHIFT;
            temp = InputValue;
            for (int j = 0; j <= SHIFT; j++)
            {
                OutString[k++] = ((temp & Mask) == 0 ? '0' : '1');
                temp <<= 1;
            } 
            //return OutString;
            string output="";
            for (int i = 0; i < OutString.Length; i++)
            {
                output += OutString[i];
            }
            return output;
        }
    }
}
